package com.aaa.order;

import com.aaa.order.config.RuleConfig;
import com.aaa.order.rule.MyRule;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.annotation.MapperScans;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author ：Username 刘亦辰（59372312@qq.com）
 * @date ：Created in 2022/11/18 14:51
 * @description：
 * @modified By：
 * @version:
 */
@SpringBootApplication
@MapperScan(basePackages = "com.aaa.order.dao")
//ribbon 微服务策略。自己定义
@RibbonClient(value = "shop-product",configuration = RuleConfig.class)
@EnableFeignClients  //开启openfeign注解驱动
public class OrderApp {
    public static void main(String[] args) {
        SpringApplication.run(OrderApp.class,args);
    }

    @Bean
    @LoadBalanced //告诉resttemplate使用ribbon完成负载均衡
    public RestTemplate restTemplate(){
        RestTemplate restTemplate = new RestTemplate();
        return restTemplate;
    }
}